package com.hotelsystem.reservations.reservations;

import java.io.File;
import java.util.Date;

/**
 * Class providing logic implemented by number of 
 * threads for move reservations from future to current
 * 
 * @author Peter Lazarov
 *
 */
public class CurrentReservationsWorker extends ReservationsWorker {
	
	public CurrentReservationsWorker(File[] files, String sourceDirectory, String destinationDirectory) {
		super(files,sourceDirectory,destinationDirectory);
	}
	
	/**
	 * Moves all reservations from source directory if reservation's end date is before now in destination directory  
	 */
	@Override
	protected void findFilesToMove() {

		for(File file : files) {
			Reservation r = readReservation(file.getName());
			Date now = new Date();
			if(r.getEndDate().before(now)) {
				moveFile(file);
			}
		}
	}
}